package com.oocl.data.producer;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.Date;

import com.oocl.pojo.Books;

public class DataProducer {
	
	
    public static void produce(){
    	OutputStream out = null;
    	ObjectOutputStream o =null;
		try {
			out = new  FileOutputStream("data.txt");
		     o = new ObjectOutputStream(out);
    	 for(int i=1;i<=10000;i++){
    		Books book = new Books(i,"book"+i,new Date(),"AA"+i,((int)Math.random()*50)+0.50,true,"beijing");
				o.writeObject(book);
				// TODO Auto-generated catch block
			}
    	 o.writeObject(null);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				o.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
    }
}
